/*** 
 * @Author: Yanan Chen
 * @Date: 2021-11-02 13:47:03
 * @LastEditTime: 2021-11-19 14:26:01
 * @LastEditors: Yanan Chen
 * @Description: 
 * @FilePath: \sadwinner\fw\esp32\Src\APP\app_base.h
 * @
 */
#ifndef PRJ_APP_BASE_H
#define PRJ_APP_BASE_H
#include "hal_function.h"
enum class FSM_MODE
{
    ENTER,
    EXIT,
    RUN,
};

enum class FSM_EVENT
{
    EMPTY,
    ENTER,
    EXIT,
    RUN,
};

class AppFSM
{
public:
    AppFSM(){};
    ~AppFSM(){};
    
    virtual void enter(){};
    virtual void exit(){};
    virtual void run(void *arg){};

    FSM_EVENT getEvent(){FSM_EVENT tevent = this->event; this->event = FSM_EVENT::EMPTY;return tevent;}
    void setEvent(FSM_EVENT evt){this->event = evt;}
private:
    FSM_EVENT event;
};



//================================message===============================

enum class MessageType
{
    RUN_MODE,
    BUTTON,
    BLE,
    WIFI,
    UI,
};
/*------------------------runmode evt--------------------------*/
enum class RunMode
{
    RUN_MODE,
    SLEEP_MODE,
    MODE_MAX,
};

typedef struct
{
    RunMode mode;
}MessageRunMode;



/*------------------------button evt--------------------------*/
enum class ButtonNum
{
    UP,
    DOWN,
    TOUCH,
};

enum class ButtonStatus
{
    EMPTY,
    SHORT,
    LONG,
    CONTINUE,
};

typedef struct
{
    ButtonNum button; 
    ButtonStatus status;
}MessageButton;

/*------------------------WIFI evt--------------------------*/


/*------------------------BLE evt--------------------------*/

//message
typedef struct
{
    MessageType type; //
    union 
    {
        MessageButton button;
        MessageRunMode mode;
    }message;
    
}MessageHandle;



#endif